from __future__ import annotations
from abc import ABC, abstractmethod
from typing import TypedDict, Optional, List, Tuple

from base.common_enum import Camp, Rarity
from base.ship_enum import ShipType
from base.gear_enum import GearType


class Gear(ABC):
    @abstractmethod
    def __init__(self, name: str, gear_type: GearType):
        self._name = name
        self._gear_type = gear_type

    @property
    def name(self):
        """装备名"""
        return self._name

    @property
    def gear_type(self):
        """装备类型"""
        return self._gear_type



class _AttrInc(TypedDict, total=False):
    fp: int
    avi: int
    eva: int
    aa: int
    trp: int
    rld: int
    hp: int
    asw: int
    oxy: int
    spd: int
    acc: int
    lck: int


class Gun(Gear):
    gear_types = [GearType.DD_MAIN_GUN, GearType.CL_MAIN_GUN, GearType.BB_MAIN_GUN]

    def __init__(self, name: str, gear_type: GearType,
                 rarity: Rarity, enhancement_level: int,
                 attr_inc: _AttrInc, dmg: int, count: int,
                 fr: float, armor_mod: Tuple[float, float, float],
                 damage_modifier: float, attr_eff: float,
                 camp: Optional[Camp], equippable: List[ShipType]):
        """
        舰炮类, 包括大型舰炮, 中型舰炮, 小型舰炮.
        :param name: 装备名
        :param gear_type: 装备类型
        :param rarity: 稀有度
        :param enhancement_level: 强化等级
        :param attr_inc: 属性提升
        :param dmg: 单次伤害
        :param count: 伤害次数
        :param fr: 射速
        :param armor_mod: 对甲比例
        :param damage_modifier: 伤害修正比例
        :param attr_eff: 属性效率
        :param camp: 所属阵营
        :param equippable: 适用舰种
        """
        if gear_type in self.gear_types:
            super().__init__(name, gear_type)
        else:
            raise ValueError("装备类型不属于舰炮")
        self._name = name
        self._gear_type = gear_type
        self._rarity = rarity
        self._enhancement_level = enhancement_level
        self._attr_inc = attr_inc
        self._dmg = dmg
        self._count = count
        self._fr = fr
        self._armor_mod = armor_mod
        self._damage_modifier = damage_modifier
        self._attr_eff = attr_eff
        self._camp = camp
        self._equippable = equippable

    @property
    def rarity(self):
        """稀有度"""
        return self._rarity

    @property
    def enhancement_level(self):
        """强化等级"""
        return self._enhancement_level

    @property
    def attr_inc(self):
        """属性提升"""
        return self._attr_inc

    @property
    def dmg(self):
        """单次伤害"""
        return self._dmg

    @property
    def count(self):
        """伤害次数"""
        return self._count

    @property
    def fr(self):
        """射速"""
        return self._fr

    @property
    def armor_mod(self):
        """对甲比例"""
        return self._armor_mod

    @property
    def damage_modifier(self):
        """伤害修正比例"""
        return self._damage_modifier

    @property
    def attr_eff(self):
        """属性效率"""
        return self._attr_eff

    @property
    def camp(self):
        """所属阵营"""
        return self._camp

    @property
    def equippable(self):
        """适用舰种"""
        return self._equippable
